package charley.wu.executor.test;

import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * 功能描述
 *
 * @author Charley
 * @since 1.0
 */
public class CustomerPolicy implements RejectedExecutionHandler {

  private long rejectCount = 0;

  public CustomerPolicy() {
  }

  /**
   * Always throws RejectedExecutionException.
   *
   * @param r the runnable task requested to be executed
   * @param e the executor attempting to execute this task
   * @throws RejectedExecutionException always
   */
  public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
    rejectCount++;
  }

  public void printCount(){
    System.out.println("Reject num: "+rejectCount);
  }
}
